home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: "Best fit" algorithm (help)
- Date: 27 Mar 1996 12:11:25 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4jbb9d$g14@news.xs4all.nl>
- References: <APC&7'0'22b6b83'874@peg.apc.org> <4j9215INNgbo@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
-
- > >I am looking for a "best fit" algorithm.
- > >The problem I have is very similar to finding the best way of fitting the
- > >maximum number of songs on (say) 45 minute tape.
-
- >Assuming that you don't care _which_ songs go on the tape, try a ``greedy''
- >approach. Always add to the tape a song which will leave the most free space.
-
- >This means starting with the smallest one, and adding the next bigger one and
- >so on. This should yield an optimal solution for the constraint of maximizing
- >the number of songs that go on the tape. It won't minimize the left-over space,
- >however.
-
- Hmmm. I think the user wants to minimize just that (unused space).
- To do that, you should pick the *largest* item that will still fit.
- Knuth (?) has proof that this is guaranteed to use less than twice
- the minimum possible space to fit all items, and *likely* to use
- much less than that maximum.
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-